# include some definitions
-include ./def.mk

#TEST_MK=1

PROG	:= calc

ifeq ($(TEST_MK), 1)
all:
	@echo TOPDIR=$(TOPDIR)
else
all:	$(PROG)	
endif

.PHONY:	all clean cleanobj cleantmp

quiet	=
Q	=
VERBOSE	= 0
export quiet Q VERBOSE

CC	:= gcc
LD	:= gcc
BISON	:= bison
INCLUDE	:= $(TOPDIR)/include

DEFINE := SYS32

CFLAGS	:= -Wall -g -I${INCLUDE} -fms-extensions -D${DEFINE} 
BFLAGS	:= -t
LDFLAGS	:= -lnsl -lm -lc

# find *.c -> add into *.o
objs :=	$(patsubst %.c, %.o, $(wildcard *.c)) 		\
	$(patsubst %.c, %.o, $(wildcard lib/*.c))	\

$(PROG): ${objs}
	${LD} ${LDFLAGS} ${objs} -o $(PROG)

# since exp.c/exp.y -> exp.o, use `::'
$(objs):: %.o:%.c
	$(CC) $(CFLAGS) -o $@ -c $<

$(parsers): %.c:%.y
	$(BISON) $(BFLAGS) $< -o $@

clean: cleanobj
	-rm -f $(PROG) 
cleanobj:
	-rm -f $(objs)

